package mulMan.domain;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Observable;


public class ListOfPlaylists extends Observable implements List<PlaylistModel>{
	
	private List<PlaylistModel> list;
	
	public ListOfPlaylists() {
		list = new ArrayList<PlaylistModel>();
	}
	
	
	
	public PlaylistModel remove(int index) {
		try {
			list.get(index).deletePlaylist();
		} catch (Exception e) {
			e.printStackTrace();
		}
		this.get(index).deleteObservers();
		PlaylistModel result = list.remove(index);
		setChanged();
		notifyObservers();
		return result;
	}

	public boolean add(PlaylistModel e) {
		boolean result = list.add(e);
		setChanged();
		notifyObservers();
		return result;
	}

	public void add(int index, PlaylistModel element) {
		setChanged();
		notifyObservers();
		list.add(index, element);
	}

	public boolean addAll(Collection<? extends PlaylistModel> c) {
		boolean result = list.addAll(c);
		setChanged();
		notifyObservers();
		return result;
	}

	public boolean addAll(int index, Collection<? extends PlaylistModel> c) {
		boolean result = list.addAll(index, c);
		setChanged();
		notifyObservers();
		return result;
	}

	public void clear() {
		list.clear();
	}

	public boolean contains(Object o) {
		return list.contains(o);
	}

	public boolean containsAll(Collection<?> c) {
		return list.containsAll(c);
	}

	public PlaylistModel get(int index) {
		return list.get(index);
	}

	public int indexOf(Object o) {
		return list.indexOf(o);
	}

	public boolean isEmpty() {
		return list.isEmpty();
	}

	public Iterator<PlaylistModel> iterator() {
		return list.iterator();
	}

	public int lastIndexOf(Object o) {
		return list.lastIndexOf(o);
	}

	public ListIterator<PlaylistModel> listIterator() {
		return list.listIterator();
	}

	public ListIterator<PlaylistModel> listIterator(int index) {
		return list.listIterator(index);
	}

	public boolean remove(Object o) {
		try {
			((PlaylistModel)o).deletePlaylist();
		} catch (Exception e) {
			e.printStackTrace();
		}
		((PlaylistModel)o).deleteObservers();
		boolean result = list.remove(o);
		setChanged();
		notifyObservers();
		return result;
	}

	public boolean removeAll(Collection<?> c) {
		for (Object o : c) {
			try {
				((PlaylistModel)o).deletePlaylist();
			} catch (Exception e) {
				e.printStackTrace();
			}
			((PlaylistModel)o).deleteObservers();
		}
		boolean result = list.removeAll(c);
		setChanged();
		notifyObservers();
		return result;
	}

	public boolean retainAll(Collection<?> c) {
		return list.retainAll(c);
	}

	public PlaylistModel set(int index, PlaylistModel element) {
		return list.set(index, element);
	}

	public int size() {
		return list.size();
	}

	public List<PlaylistModel> subList(int fromIndex, int toIndex) {
		return list.subList(fromIndex, toIndex);
	}

	public Object[] toArray() {
		return list.toArray();
	}

	public <T> T[] toArray(T[] a) {
		return list.toArray(a);
	}
}
